/* Copyright 2011 Elektrobit Wireless Communications Oy (EB)


  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 2 as 
  published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along
  with this program; if not, write to the Free Software Foundation, Inc.,
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


 *All rights reserved 
 *Version:Elektrobit_Qt_1.0.0_20110305 */


#include "filmdetailpage.h"
#include <appcommon.h>
#include <servicemanager.h>
#include <QApplication>
#include <QDesktopServices>
#include <QDir>

FilmDetailPage::FilmDetailPage(QObject *parent) : Page(parent) {
    this->thread = NULL;
}

int FilmDetailPage::init() {
    this->mFilmDetailPageView = qobject_cast<FilmDetailPageView *>(this->mPageView);
    if(!mFilmDetailPageView) {
        return -1;
    }
    return 0;
}


int FilmDetailPage::uninit() {
    
    return 0;
}

int FilmDetailPage::beforeShow() {
    this->mFilmDetailPageView->showViewUseQml(this);

    return 0;
}

int FilmDetailPage::afterShow() {
    return 0;
}

int FilmDetailPage::onClick(int key) {

    return 0;
}

int FilmDetailPage::onTouch(const QString &type, const QHash<QString, QString> *args) {
    return 0;
}
QString FilmDetailPage::getBillImagePath(void) {
    return this->property("bill_image").toString();
}

QString FilmDetailPage::getDetailImagePath(void){
    return this->property("detail_image").toString();
}


void FilmDetailPage::onIconClick(QString id) {
    if(id == QString("return")) {
        SERVICE(RouterService)->goBack();
        return;
    }
    if(id == QString("play")){
//        QDir dir(this->property("file_url").toString());
//        QUrl url("File:///" + dir.absolutePath());
//        APPINFO << url.toString();
//        QDesktopServices::openUrl(this->property("file_url").toString());
        if(thread){
            delete thread;
            thread = NULL;
        }
        thread = new MyThread(this->property("file_url").toString());
        return;
    }
}
































